package cn.jlonely.xyhx.Exception;

import cn.jlonely.xyhx.utils.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(AnalysisException.class)
    public Result handleAnalysisException(AnalysisException e) {
        return Result.error(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handleGlobalException(Exception e) {
        return Result.error("系统错误: " + e.getMessage());
    }
}